package com.example.mobile2021606128wje0507;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class PartActivity extends AppCompatActivity {

    private Button btnPartLook;
    private TextView tvPartResult;
    private Button btnPartOk;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_part );
        initView();
        btnPartLook.setOnClickListener( new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(PartActivity.this,MainActivity.class);
                startActivityForResult( intent,1 );
            }
        } );
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult( requestCode, resultCode, data );
        if (requestCode==1&&resultCode==RESULT_OK){
            tvPartResult.setText( data.getStringExtra( "part" ) );
        }
    }

    private void initView() {
        btnPartLook = (Button) findViewById( R.id.btnPartLook );
        tvPartResult = (TextView) findViewById( R.id.tvPartResult );
        btnPartOk = (Button) findViewById( R.id.btnPartOk );
    }
}